package com.mq.activemq.consume;

import org.apache.activemq.Message;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.MapMessage;

/**
 * 消息的消费者
 * 处理消息生产者发送过来的消息
 */
@Component
public class messageConsume {
    /**
     * 接收消息
     */
    @JmsListener(destination = "testQueue")
    public void receive(Message message) throws JMSException {
        MapMessage mapMessage = (MapMessage) message;
        String key1 = mapMessage.getString("key1");
        Integer key2 = mapMessage.getInt("key2");
        System.out.println("消费者接收到的MapMessage信息是："+key1+","+key2);
    }
}
